#include <fcntl.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "job.h"

/*
 * command syntax
 *     stat
 */
void usage() { printf("Usage: stat\n"); }
#define debug
void pr(const char *out) {
#ifdef debug
  error_sys(out);
#endif
}
int main(int argc, char *argv[]) {
  struct jobcmd statcmd;
  int fd;

  if (argc != 1) {
    usage();
    return 1;
  }

  statcmd.type = STAT;
  statcmd.defpri = 0;
  statcmd.owner = getuid();
  statcmd.argnum = 0;
  strcpy(statcmd.data, "\0");
  // pr("fd");
  if ((fd = open(FIFO, O_WRONLY)) < 0) error_sys("stat open fifo failed");
  // pr("open");
  if (write(fd, &statcmd, DATALEN) < 0) error_sys("stat write failed");
  // pr("finish");
  close(fd);
  return 0;
}
#undef debug
